/***
*
* File: wp_saveloadmzgkjobs.inc
* Auth: Damian Wojdat
* Date: 15.09.2011
* Desc: Loading functions.
* TODO: Transfer this to a better place.
*
*************************************************************************************************************/

LoadMzgkJobCheckpointA()
{
	new arrCoords[36][64];
	new strFromFile2[1000];
	new File: file = fopen("jobs/mzgkjobcheckpointa.cfg", io_read);
	if (file)
	{
		fread(file, strFromFile2);
		split2(strFromFile2, arrCoords, '|');
		MzgkJob[CheckPoint0ax] = floatstr(arrCoords[0]);
		MzgkJob[CheckPoint0ay] = floatstr(arrCoords[1]);
		MzgkJob[CheckPoint0az] = floatstr(arrCoords[2]);
		MzgkJob[CheckPoint1ax] = floatstr(arrCoords[3]);
		MzgkJob[CheckPoint1ay] = floatstr(arrCoords[4]);
		MzgkJob[CheckPoint1az] = floatstr(arrCoords[5]);
		MzgkJob[CheckPoint2ax] = floatstr(arrCoords[6]);
		MzgkJob[CheckPoint2ay] = floatstr(arrCoords[7]);
		MzgkJob[CheckPoint2az] = floatstr(arrCoords[8]);
		MzgkJob[CheckPoint3ax] = floatstr(arrCoords[9]);
		MzgkJob[CheckPoint3ay] = floatstr(arrCoords[10]);
		MzgkJob[CheckPoint3az] = floatstr(arrCoords[11]);
		MzgkJob[CheckPoint4ax] = floatstr(arrCoords[12]);
		MzgkJob[CheckPoint4ay] = floatstr(arrCoords[13]);
		MzgkJob[CheckPoint4az] = floatstr(arrCoords[14]);
		MzgkJob[CheckPoint5ax] = floatstr(arrCoords[15]);
		MzgkJob[CheckPoint5ay] = floatstr(arrCoords[16]);
		MzgkJob[CheckPoint5az] = floatstr(arrCoords[17]);
		MzgkJob[CheckPoint6ax] = floatstr(arrCoords[18]);
		MzgkJob[CheckPoint6ay] = floatstr(arrCoords[19]);
		MzgkJob[CheckPoint6az] = floatstr(arrCoords[20]);
		MzgkJob[CheckPoint7ax] = floatstr(arrCoords[21]);
		MzgkJob[CheckPoint7ay] = floatstr(arrCoords[22]);
		MzgkJob[CheckPoint7az] = floatstr(arrCoords[23]);
		MzgkJob[CheckPoint8ax] = floatstr(arrCoords[24]);
		MzgkJob[CheckPoint8ay] = floatstr(arrCoords[25]);
		MzgkJob[CheckPoint8az] = floatstr(arrCoords[26]);
		MzgkJob[CheckPoint9ax] = floatstr(arrCoords[27]);
		MzgkJob[CheckPoint9ay] = floatstr(arrCoords[28]);
		MzgkJob[CheckPoint9az] = floatstr(arrCoords[29]);
		MzgkJob[CheckPoint10ax] = floatstr(arrCoords[30]);
		MzgkJob[CheckPoint10ay] = floatstr(arrCoords[31]);
		MzgkJob[CheckPoint10az] = floatstr(arrCoords[32]);
		MzgkJob[CheckPoint11ax] = floatstr(arrCoords[33]);
		MzgkJob[CheckPoint11ay] = floatstr(arrCoords[34]);
		MzgkJob[CheckPoint11az] = floatstr(arrCoords[35]);
		#if defined DEBUG
			print("[INFO:] Mzgk job checkpoint A loaded");
		#endif
	}
	else
	{
		print("[INFO:] Failed to load Mzgk job checkpoint A.");
	}
	fclose(file);
	return 1;
}

LoadMzgkJobCheckpointB()
{
	new arrCoords[36][64];
	new strFromFile2[640];
	new File: file = fopen("jobs/mzgkjobcheckpointb.cfg", io_read);
	if (file)
	{
		fread(file, strFromFile2);
		split2(strFromFile2, arrCoords, '|');
		MzgkJob[CheckPoint0bx] = floatstr(arrCoords[0]);
		MzgkJob[CheckPoint0by] = floatstr(arrCoords[1]);
		MzgkJob[CheckPoint0bz] = floatstr(arrCoords[2]);
		MzgkJob[CheckPoint1bx] = floatstr(arrCoords[3]);
		MzgkJob[CheckPoint1by] = floatstr(arrCoords[4]);
		MzgkJob[CheckPoint1bz] = floatstr(arrCoords[5]);
		MzgkJob[CheckPoint2bx] = floatstr(arrCoords[6]);
		MzgkJob[CheckPoint2by] = floatstr(arrCoords[7]);
		MzgkJob[CheckPoint2bz] = floatstr(arrCoords[8]);
		MzgkJob[CheckPoint3bx] = floatstr(arrCoords[9]);
		MzgkJob[CheckPoint3by] = floatstr(arrCoords[10]);
		MzgkJob[CheckPoint3bz] = floatstr(arrCoords[11]);
		MzgkJob[CheckPoint4bx] = floatstr(arrCoords[12]);
		MzgkJob[CheckPoint4by] = floatstr(arrCoords[13]);
		MzgkJob[CheckPoint4bz] = floatstr(arrCoords[14]);
		MzgkJob[CheckPoint5bx] = floatstr(arrCoords[15]);
		MzgkJob[CheckPoint5by] = floatstr(arrCoords[16]);
		MzgkJob[CheckPoint5bz] = floatstr(arrCoords[17]);
		MzgkJob[CheckPoint6bx] = floatstr(arrCoords[18]);
		MzgkJob[CheckPoint6by] = floatstr(arrCoords[19]);
		MzgkJob[CheckPoint6bz] = floatstr(arrCoords[20]);
		MzgkJob[CheckPoint7bx] = floatstr(arrCoords[21]);
		MzgkJob[CheckPoint7by] = floatstr(arrCoords[22]);
		MzgkJob[CheckPoint7bz] = floatstr(arrCoords[23]);
		MzgkJob[CheckPoint8bx] = floatstr(arrCoords[24]);
		MzgkJob[CheckPoint8by] = floatstr(arrCoords[25]);
		MzgkJob[CheckPoint8bz] = floatstr(arrCoords[26]);
		MzgkJob[CheckPoint9bx] = floatstr(arrCoords[27]);
		MzgkJob[CheckPoint9by] = floatstr(arrCoords[28]);
		MzgkJob[CheckPoint9bz] = floatstr(arrCoords[29]);
		MzgkJob[CheckPoint10bx] = floatstr(arrCoords[30]);
		MzgkJob[CheckPoint10by] = floatstr(arrCoords[31]);
		MzgkJob[CheckPoint10bz] = floatstr(arrCoords[32]);
		MzgkJob[CheckPoint11bx] = floatstr(arrCoords[33]);
		MzgkJob[CheckPoint11by] = floatstr(arrCoords[34]);
		MzgkJob[CheckPoint11bz] = floatstr(arrCoords[35]);
		#if defined DEBUG
			print("[INFO:] MZGK job checkpoint B loaded");
		#endif
	}
	else
	{
		print("[INFO:] Failed to load MZGK job checkpoint B.");
	}
	fclose(file);
	return 1;
}

LoadSweeperJobCheckpointA()
{
	new arrCoords[36][64];
	new strFromFile2[640];
	new File: file = fopen("jobs/sweeperjobcheckpointa.cfg", io_read);
	if (file)
	{
		fread(file, strFromFile2);
		split2(strFromFile2, arrCoords, '|');
		SweeperJob[CheckPoint0ax] = floatstr(arrCoords[0]);
		SweeperJob[CheckPoint0ay] = floatstr(arrCoords[1]);
		SweeperJob[CheckPoint0az] = floatstr(arrCoords[2]);
		SweeperJob[CheckPoint1ax] = floatstr(arrCoords[3]);
		SweeperJob[CheckPoint1ay] = floatstr(arrCoords[4]);
		SweeperJob[CheckPoint1az] = floatstr(arrCoords[5]);
		SweeperJob[CheckPoint2ax] = floatstr(arrCoords[6]);
		SweeperJob[CheckPoint2ay] = floatstr(arrCoords[7]);
		SweeperJob[CheckPoint2az] = floatstr(arrCoords[8]);
		SweeperJob[CheckPoint3ax] = floatstr(arrCoords[9]);
		SweeperJob[CheckPoint3ay] = floatstr(arrCoords[10]);
		SweeperJob[CheckPoint3az] = floatstr(arrCoords[11]);
		SweeperJob[CheckPoint4ax] = floatstr(arrCoords[12]);
		SweeperJob[CheckPoint4ay] = floatstr(arrCoords[13]);
		SweeperJob[CheckPoint4az] = floatstr(arrCoords[14]);
		SweeperJob[CheckPoint5ax] = floatstr(arrCoords[15]);
		SweeperJob[CheckPoint5ay] = floatstr(arrCoords[16]);
		SweeperJob[CheckPoint5az] = floatstr(arrCoords[17]);
		SweeperJob[CheckPoint6ax] = floatstr(arrCoords[18]);
		SweeperJob[CheckPoint6ay] = floatstr(arrCoords[19]);
		SweeperJob[CheckPoint6az] = floatstr(arrCoords[20]);
		SweeperJob[CheckPoint7ax] = floatstr(arrCoords[21]);
		SweeperJob[CheckPoint7ay] = floatstr(arrCoords[22]);
		SweeperJob[CheckPoint7az] = floatstr(arrCoords[23]);
		SweeperJob[CheckPoint8ax] = floatstr(arrCoords[24]);
		SweeperJob[CheckPoint8ay] = floatstr(arrCoords[25]);
		SweeperJob[CheckPoint8az] = floatstr(arrCoords[26]);
		SweeperJob[CheckPoint9ax] = floatstr(arrCoords[27]);
		SweeperJob[CheckPoint9ay] = floatstr(arrCoords[28]);
		SweeperJob[CheckPoint9az] = floatstr(arrCoords[29]);
		SweeperJob[CheckPoint10ax] = floatstr(arrCoords[30]);
		SweeperJob[CheckPoint10ay] = floatstr(arrCoords[31]);
		SweeperJob[CheckPoint10az] = floatstr(arrCoords[32]);
		SweeperJob[CheckPoint11ax] = floatstr(arrCoords[33]);
		SweeperJob[CheckPoint11ay] = floatstr(arrCoords[34]);
		SweeperJob[CheckPoint11az] = floatstr(arrCoords[35]);
		#if defined DEBUG
			print("[INFO:] Sweeper job checkpoint A loaded");
		#endif
	}
	else
	{
		print("[INFO:] Failed to load Sweeper job checkpoint A.");
	}
	fclose(file);
	return 1;
}

LoadSweeperJobCheckpointB()
{
	new arrCoords[36][64];
	new strFromFile2[640];
	new File: file = fopen("jobs/sweeperjobcheckpointb.cfg", io_read);
	if (file)
	{
		fread(file, strFromFile2);
		split2(strFromFile2, arrCoords, '|');
		SweeperJob[CheckPoint0bx] = floatstr(arrCoords[0]);
		SweeperJob[CheckPoint0by] = floatstr(arrCoords[1]);
		SweeperJob[CheckPoint0bz] = floatstr(arrCoords[2]);
		SweeperJob[CheckPoint1bx] = floatstr(arrCoords[3]);
		SweeperJob[CheckPoint1by] = floatstr(arrCoords[4]);
		SweeperJob[CheckPoint1bz] = floatstr(arrCoords[5]);
		SweeperJob[CheckPoint2bx] = floatstr(arrCoords[6]);
		SweeperJob[CheckPoint2by] = floatstr(arrCoords[7]);
		SweeperJob[CheckPoint2bz] = floatstr(arrCoords[8]);
		SweeperJob[CheckPoint3bx] = floatstr(arrCoords[9]);
		SweeperJob[CheckPoint3by] = floatstr(arrCoords[10]);
		SweeperJob[CheckPoint3bz] = floatstr(arrCoords[11]);
		SweeperJob[CheckPoint4bx] = floatstr(arrCoords[12]);
		SweeperJob[CheckPoint4by] = floatstr(arrCoords[13]);
		SweeperJob[CheckPoint4bz] = floatstr(arrCoords[14]);
		SweeperJob[CheckPoint5bx] = floatstr(arrCoords[15]);
		SweeperJob[CheckPoint5by] = floatstr(arrCoords[16]);
		SweeperJob[CheckPoint5bz] = floatstr(arrCoords[17]);
		SweeperJob[CheckPoint6bx] = floatstr(arrCoords[18]);
		SweeperJob[CheckPoint6by] = floatstr(arrCoords[19]);
		SweeperJob[CheckPoint6bz] = floatstr(arrCoords[20]);
		SweeperJob[CheckPoint7bx] = floatstr(arrCoords[21]);
		SweeperJob[CheckPoint7by] = floatstr(arrCoords[22]);
		SweeperJob[CheckPoint7bz] = floatstr(arrCoords[23]);
		SweeperJob[CheckPoint8bx] = floatstr(arrCoords[24]);
		SweeperJob[CheckPoint8by] = floatstr(arrCoords[25]);
		SweeperJob[CheckPoint8bz] = floatstr(arrCoords[26]);
		SweeperJob[CheckPoint9bx] = floatstr(arrCoords[27]);
		SweeperJob[CheckPoint9by] = floatstr(arrCoords[28]);
		SweeperJob[CheckPoint9bz] = floatstr(arrCoords[29]);
		SweeperJob[CheckPoint10bx] = floatstr(arrCoords[30]);
		SweeperJob[CheckPoint10by] = floatstr(arrCoords[31]);
		SweeperJob[CheckPoint10bz] = floatstr(arrCoords[32]);
		SweeperJob[CheckPoint11bx] = floatstr(arrCoords[33]);
		SweeperJob[CheckPoint11by] = floatstr(arrCoords[34]);
		SweeperJob[CheckPoint11bz] = floatstr(arrCoords[35]);
		#if defined DEBUG
			print("[INFO:] Sweeper job checkpoint B loaded");
		#endif
	}
	else
	{
		print("[INFO:] Failed to load Sweeper job checkpoint B.");
	}
	fclose(file);
	return 1;
}

LoadFarmerJob()
{
	new arrCoords[7][64];
	new strFromFile2[256];
	new File: file = fopen("jobs/FarmerJob.cfg", io_read);
	if (file)
	{
		fread(file, strFromFile2);
		split2(strFromFile2, arrCoords, '|');
		FarmerJob[TakeJobX] = floatstr(arrCoords[0]);
		FarmerJob[TakeJobY] = floatstr(arrCoords[1]);
		FarmerJob[TakeJobZ] = floatstr(arrCoords[2]);
		FarmerJob[TakeJobWorld] = strval(arrCoords[3]);
		FarmerJob[TakeJobInterior] = strval(arrCoords[4]);
		FarmerJob[TakeJobAngle] = floatstr(arrCoords[5]);
		FarmerJob[TakeJobPickupID] = strval(arrCoords[6]);
        FarmerJob[TakeJobPickupID] = CreateDynamicPickup(1239,1,FarmerJob[TakeJobX],FarmerJob[TakeJobY],FarmerJob[TakeJobZ]);
		#if defined DEBUG
			print("[INFO:] Farmer job loaded");
		#endif
	}
	fclose(file);
	return 1;
}

SaveFarmerJob()
{
	new File: file2;
	new coordsstring[512];
	format(coordsstring, sizeof(coordsstring), "%f|%f|%f|%d|%d|%f|%d\n",
	FarmerJob[TakeJobX],
	FarmerJob[TakeJobY],
	FarmerJob[TakeJobZ],
	FarmerJob[TakeJobWorld],
	FarmerJob[TakeJobInterior],
	FarmerJob[TakeJobAngle],
	FarmerJob[TakeJobPickupID]);
	file2 = fopen("jobs/FarmerJob.cfg", io_write);
	fwrite(file2, coordsstring);
	fclose(file2);
	return 1;
}

LoadFarmerJobCheckpointA()
{
	new arrCoords[36][64];
	new strFromFile2[640];
	new File: file = fopen("jobs/Farmerjobcheckpointa.cfg", io_read);
	if (file)
	{
		fread(file, strFromFile2);
		split2(strFromFile2, arrCoords, '|');
		FarmerJob[CheckPoint0ax] = floatstr(arrCoords[0]);
		FarmerJob[CheckPoint0ay] = floatstr(arrCoords[1]);
		FarmerJob[CheckPoint0az] = floatstr(arrCoords[2]);
		FarmerJob[CheckPoint1ax] = floatstr(arrCoords[3]);
		FarmerJob[CheckPoint1ay] = floatstr(arrCoords[4]);
		FarmerJob[CheckPoint1az] = floatstr(arrCoords[5]);
		FarmerJob[CheckPoint2ax] = floatstr(arrCoords[6]);
		FarmerJob[CheckPoint2ay] = floatstr(arrCoords[7]);
		FarmerJob[CheckPoint2az] = floatstr(arrCoords[8]);
		FarmerJob[CheckPoint3ax] = floatstr(arrCoords[9]);
		FarmerJob[CheckPoint3ay] = floatstr(arrCoords[10]);
		FarmerJob[CheckPoint3az] = floatstr(arrCoords[11]);
		FarmerJob[CheckPoint4ax] = floatstr(arrCoords[12]);
		FarmerJob[CheckPoint4ay] = floatstr(arrCoords[13]);
		FarmerJob[CheckPoint4az] = floatstr(arrCoords[14]);
		#if defined DEBUG
			print("[INFO:] Farmer job checkpoint A loaded");
		#endif
	}
	else
	{
		print("[INFO:] Failed to load Farmer job checkpoint A.");
	}
	fclose(file);
	return 1;
}

LoadFarmerJobCheckpointB()
{
	new arrCoords[39][64];
	new strFromFile2[640];
	new File: file = fopen("jobs/Farmerjobcheckpointb.cfg", io_read);
	if (file)
	{
		fread(file, strFromFile2);
		split2(strFromFile2, arrCoords, '|');
		FarmerJob[CheckPoint0bx] = floatstr(arrCoords[0]);
		FarmerJob[CheckPoint0by] = floatstr(arrCoords[1]);
		FarmerJob[CheckPoint0bz] = floatstr(arrCoords[2]);
		FarmerJob[CheckPoint1bx] = floatstr(arrCoords[3]);
		FarmerJob[CheckPoint1by] = floatstr(arrCoords[4]);
		FarmerJob[CheckPoint1bz] = floatstr(arrCoords[5]);
		FarmerJob[CheckPoint2bx] = floatstr(arrCoords[6]);
		FarmerJob[CheckPoint2by] = floatstr(arrCoords[7]);
		FarmerJob[CheckPoint2bz] = floatstr(arrCoords[8]);
		FarmerJob[CheckPoint3bx] = floatstr(arrCoords[9]);
		FarmerJob[CheckPoint3by] = floatstr(arrCoords[10]);
		FarmerJob[CheckPoint3bz] = floatstr(arrCoords[11]);
		FarmerJob[CheckPoint4bx] = floatstr(arrCoords[12]);
		FarmerJob[CheckPoint4by] = floatstr(arrCoords[13]);
		FarmerJob[CheckPoint4bz] = floatstr(arrCoords[14]);
		FarmerJob[CheckPoint5bx] = floatstr(arrCoords[15]);
		FarmerJob[CheckPoint5by] = floatstr(arrCoords[16]);
		FarmerJob[CheckPoint5bz] = floatstr(arrCoords[17]);
		FarmerJob[CheckPoint6bx] = floatstr(arrCoords[18]);
		FarmerJob[CheckPoint6by] = floatstr(arrCoords[19]);
		FarmerJob[CheckPoint6bz] = floatstr(arrCoords[20]);
		FarmerJob[CheckPoint7bx] = floatstr(arrCoords[21]);
		FarmerJob[CheckPoint7by] = floatstr(arrCoords[22]);
		FarmerJob[CheckPoint7bz] = floatstr(arrCoords[23]);
		FarmerJob[CheckPoint8bx] = floatstr(arrCoords[24]);
		FarmerJob[CheckPoint8by] = floatstr(arrCoords[25]);
		FarmerJob[CheckPoint8bz] = floatstr(arrCoords[26]);
		FarmerJob[CheckPoint9bx] = floatstr(arrCoords[27]);
		FarmerJob[CheckPoint9by] = floatstr(arrCoords[28]);
		FarmerJob[CheckPoint9bz] = floatstr(arrCoords[29]);
		FarmerJob[CheckPoint10bx] = floatstr(arrCoords[30]);
		FarmerJob[CheckPoint10by] = floatstr(arrCoords[31]);
		FarmerJob[CheckPoint10bz] = floatstr(arrCoords[32]);
		FarmerJob[CheckPoint11bx] = floatstr(arrCoords[33]);
		FarmerJob[CheckPoint11by] = floatstr(arrCoords[34]);
		FarmerJob[CheckPoint11bz] = floatstr(arrCoords[35]);
		FarmerJob[CheckPoint12bx] = floatstr(arrCoords[36]);
		FarmerJob[CheckPoint12by] = floatstr(arrCoords[37]);
		FarmerJob[CheckPoint12bz] = floatstr(arrCoords[38]);
		#if defined DEBUG
			print("[INFO:] Farmer job checkpoint B loaded");
		#endif
	}
	else
	{
		print("[INFO:] Failed to load Farmer job checkpoint B.");
	}
	fclose(file);
	return 1;
}

LoadFarmerJobCheckpointC()
{
	new arrCoords[15][64];
	new strFromFile2[640];
	new File: file = fopen("jobs/Farmerjobcheckpointc.cfg", io_read);
	if (file)
	{
		fread(file, strFromFile2);
		split2(strFromFile2, arrCoords, '|');
		FarmerJob[CheckPoint13cx] = floatstr(arrCoords[0]);
		FarmerJob[CheckPoint13cy] = floatstr(arrCoords[1]);
		FarmerJob[CheckPoint13cz] = floatstr(arrCoords[2]);
		FarmerJob[CheckPoint14cx] = floatstr(arrCoords[3]);
		FarmerJob[CheckPoint14cy] = floatstr(arrCoords[4]);
		FarmerJob[CheckPoint14cz] = floatstr(arrCoords[5]);
		FarmerJob[CheckPoint15cx] = floatstr(arrCoords[6]);
		FarmerJob[CheckPoint15cy] = floatstr(arrCoords[7]);
		FarmerJob[CheckPoint15cz] = floatstr(arrCoords[8]);
		FarmerJob[CheckPoint16cx] = floatstr(arrCoords[9]);
		FarmerJob[CheckPoint16cy] = floatstr(arrCoords[10]);
		FarmerJob[CheckPoint16cz] = floatstr(arrCoords[11]);
		FarmerJob[CheckPoint17cx] = floatstr(arrCoords[12]);
		FarmerJob[CheckPoint17cy] = floatstr(arrCoords[13]);
		FarmerJob[CheckPoint17cz] = floatstr(arrCoords[14]);
		#if defined DEBUG
			print("[INFO:] Farmer job checkpoint C loaded");
		#endif
	}
	else
	{
		print("[INFO:] Failed to load Farmer job checkpoint C.");
	}
	fclose(file);
	return 1;
}